<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS对象原型</title>
</head>
<body>
<p id="demo"></p>
<script>
  function Person(first,last,age,eye){
    this.firstName = first;
    this.lastName = last;
    this.age = age;
    this.eyeColor = eye;
  }
//JavaScript prototype 属性也允许您为对象构造器添加新方法：
  Person.prototype.name = function (){
    return this.firstName + " " + this.lastName
  };

  var myFriend = new Person("Bill","Gates",62,"blue"
  );
  document.getElementById("demo").innerHTML =
          "My friend is " + myFriend.name();
</script>
</body>
</html>